import { BasicColumn, FormSchema } from '@/components/Table'
import { addFile, uploadFile } from '@/api/download'

export const columns: BasicColumn[] = [
  {
    title: '设备名称',
    dataIndex: 'name',
    width: 120,
  },
  {
    title: '设备编码',
    dataIndex: 'code',
    width: 120,
  },
  {
    title: '数据获取类型',
    dataIndex: 'type',
    width: 120,
  },
  {
    title: '统计参数',
    dataIndex: 'params',
    width: 180,
  },
  {
    title: '系数',
    dataIndex: 'coefficient',
    width: 80,
  },
  {
    title: '楼栋',
    dataIndex: 'building',
  },
  {
    title: '楼层',
    dataIndex: 'floor',
  },
  {
    title: '责任部门',
    dataIndex: 'dept',
    // customRender: ({ value }) => {
    //   return deptMap[value]
    // },
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '设备名称',
    component: 'Input',
    colProps: { span: 6 },
  },
]

export const scenceBuildingFormSchema: FormSchema[] = [
  {
    field: 'code',
    label: '楼栋编码',
    component: 'Input',
    required: true,
  },
  {
    field: 'nameCopy',
    label: '楼栋名称',
    component: 'Input',
    rules: [
      {
        required: true,
      },
    ],
  },
  {
    field: 'sort',
    label: '楼栋序号',
    component: 'InputNumber',
  },
]
export const scenceFloorFormSchema: FormSchema[] = [
  {
    field: 'code',
    label: '楼层编码',
    component: 'Input',
    required: true,
  },
  {
    field: 'nameCopy',
    label: '楼层名称',
    component: 'Input',
    rules: [
      {
        required: true,
      },
    ],
  },
  {
    field: 'width',
    label: '楼层宽度',
    component: 'InputNumber',
    required: true,
  },
  {
    field: 'height',
    label: '楼层高度',
    component: 'InputNumber',
    required: true,
  },
  {
    field: 'description',
    label: '描述',
    component: 'InputTextArea',
  },
  {
    field: 'file',
    label: '楼层平面图',
    component: 'ImageUpload',
    componentProps: {
      api: uploadFile,
      preApi: addFile,
      maxSize: 20,
      // value: 'id',
      // fieldNames: {
      //   label: 'fileId',
      //   key: 'id',
      //   value: 'id',
      // },
    },
    // ifShow: ({ values }) => {
    //   return JSON.stringify(values) === '{}'
    // },
  },
]
